package com.honey.mybatis.generator.dao;

import com.honey.compilation.java.AbstractJavaCompilation;
import com.honey.compilation.java.Interface;
import com.honey.core.compiler.CompilationException;
import com.honey.core.dbmapping.introspect.IntrospectSchema;
import com.honey.core.dbmapping.introspect.IntrospectSchemaColumn;
import com.honey.core.dbmapping.structure.Schema;
import com.honey.core.types.FullyQualifiedJavaType;
import com.honey.mybatis.generator.AbstractClass;
import com.honey.mybatis.generator.MybatisPlugin;
import com.honey.mybatis.generator.dependent.DependentModel;
import com.honey.mybatis.generator.entity.EntityConstant;

public class BaseDaoInterface extends AbstractClass {
	
	public BaseDaoInterface(MybatisPlugin belongPlugin,
			IntrospectSchema introspectSchema,
			IntrospectSchemaColumn introspectSchemaColumn) {
		super(belongPlugin, introspectSchema, introspectSchemaColumn);
	}

	/* (non-Javadoc)
	 * @see com.honey.mybatis.generator.AbstractClass#getAbstractJavaCompilation()
	 */
	@Override
	protected AbstractJavaCompilation getAbstractJavaCompilation()
			throws CompilationException {
		Schema schema = introspectSchema.getSchema();
		Interface answer = null;
		if( super.getDependentModel() == DependentModel.EXTEND ){
			try {
				answer =new Interface(super.getBaseDaoInterfaceClassType(null,"<"+EntityConstant.ENTITY_GENERIC_NAME+" extends "+super.getEntityInterfaceName(schema)+">"));
				
				answer.addImportedType(super.getModelClassType(introspectSchema.getSchema()));
				answer.addImportedType(DaoConstant.SQL_SESSION_PACKAGE);
				answer.addImportedType(super.getEntityInterfaceType(null));
				
			} catch (CompilationException e) {
				e.printStackTrace();
			}
		}
		return answer;
	}
	
	@Override
	protected FullyQualifiedJavaType getType() {
		
		return null;
	}

	@Override
	protected FullyQualifiedJavaType getSuperClass() {
		return super.getInversionModel().extend();
	}

	
	
}
